package com.feishi.project.test;

import javax.swing.*;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: caixq
 * Date: 2018-11-26
 * Time: 上午10:16
 */
public class B extends JFrame {
    public void init() {
        Container containerPane = getContentPane();
        containerPane.add(new JPanel() {
            private int x=30;
            private int y=30;
            private int w=600;
            private int h=600;

            //重写
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);

                //画横线
                for (int i = 0; i <= x; i++) {
                    g.drawLine(w/x*i, 0, w/x*i, w);
                }
                //画竖线
                for (int i = 0; i <= y; i++) {
                    g.drawLine(0, h/y*i, h, h/y*i);
                }
            }
        });
    }

    public static void main(String[] args) {
        B b = new B();
        b.init();
        b.setSize(660,660);
        b.setVisible(true);
    }
}
